﻿
#ifndef  MY_LOGIC_H
#define MY_LOGIC_H

#include "ILogic.h"

class CLogic :  	public ILogic
{
public:
	CLogic();
	~CLogic();

	static	CLogic* getInstance();
	static void destoryInstance();

private:
	static	CLogic* create();

public:
	virtual bool init();

public:		// 回调函数

	// 连接结果的回调
	virtual void OnConnect(int iClientId, bool bConnect, int iReconnectCount, std::string  strErr);

	// 断线重连的回调
	virtual void OnReconnectAfterOffline(int iClientId, bool bConnect, int iReconnectCount, std::string  strErr);

	// 断线的回调
	virtual void OnClose(int iClientId);

	// 处理逻辑消息
	virtual int OnLogicMsg(int	iClientId, int iMainCode, int iSubCode, const char* pBody = nullptr, int iBodyLen = 0);


	/* --------------------------------------------------------------------------
	函数说明：设置连接或断线重连时要转圈的参数
	传入参数：
	iStartCircleCountConnect,								OnConnect 状态下开始转圈的连接次数
	iEndCircleCountConnect,								OnConnect 状态下结束转圈的连接次数
	iStartCircleCountReconnectAfterOffline,	OnReconnectAfterOffline 状态下开始转圈的连接次数
	iEndCircleCountReconnectAfterOffline		OnReconnectAfterOffline 状态下结束转圈的连接次数)
	-------------------------------------------------------------------------- */
	//void  setCircleParam(int  iStartCircleCountConnect, int  iEndCircleCountConnect, int  iStartCircleCountReconnectAfterOffline, int  iEndCircleCountReconnectAfterOffline);


private:
	static CLogic*  _pLauncher;

};

#endif